import 'package:FlutterStudy/demo/LikeView.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_splash_screen/flutter_splash_screen.dart';
import 'package:player/player.dart';
import 'package:player/view/video_view.dart';

class safeAreaDemo extends StatefulWidget {
  @override
  State<safeAreaDemo> createState() => _safeAreaDemoState();
}

class _safeAreaDemoState extends State<safeAreaDemo> {
  final Player mplayer = Player();

  @override
  void initState() {
    // TODO: implement initState
    super.initState();
    mplayer.enterFullScreen();
    mplayer.setPlayerPath("");
  }

  @override
  Widget build(BuildContext context) {
    hideScreen();
    SystemChrome.setEnabledSystemUIMode(SystemUiMode.edgeToEdge);
    return MaterialApp(
      home: Container(
        decoration: const BoxDecoration(color: Colors.orange),
        child: SafeArea(
          child: LikeView(
            child: Stack(
              children: [
                Column(
                  mainAxisAlignment: MainAxisAlignment.spaceBetween,
                  children: [
                    const Text("顶部"),
                    GestureDetector(
                      onTap: () => print("我是最外层的onTap事件"),
                      child: GestureDetector(
                        onTap: () => print("我是内层的onTap事件"),
                        child: Container(
                          width: 200,
                          height: 200,
                          decoration: const BoxDecoration(color: Colors.red),
                        ),
                      ),
                    ),
                    VideoView(mPlayer: mplayer),
                    const Text("底部"),
                  ],
                ),
              ],
            ),
          ),
        ),
      ),
    );
  }

  Future<void> hideScreen() async {
    Future.delayed(Duration(milliseconds: 1800), () {
      FlutterSplashScreen.hide();
    });
  }
}

void main() {
  runApp(safeAreaDemo());
}
